package com.neusoft.common;

import com.neusoft.pojo.User;
import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/*定义的拦截器*/
public class Interceptor implements HandlerInterceptor {

    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        //从session中获取user的信息
        User user =(User)request.getSession().getAttribute("user");
        //判断用户是否登录
        if (null!=user){
//            response.sendRedirect(request.getContextPath()+"/user/login/");
            return false;
        }
        return true;
    }

}
